package com.bss.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.andy.basics.Service;
import com.bss.model.Receipt;
import com.bss.service.ReceiptService;

@Controller
@Scope("request")
public class ReceiptController extends com.andy.basics.Controller<Receipt> {

	@Autowired
	private ReceiptService receiptService;

	private Date date = new Date();

	@Override
	public Receipt create() {
		throw new UnsupportedOperationException();
	}

	@Override
	public Service<Receipt> getService() {
		throw new UnsupportedOperationException();
	}

	public void setDate(final Date date) {
		this.date = date;
	}

	public Date getDate() {
		return this.date;
	}

	public Receipt getReceipt() {
		String id = getId();
		if (id != null) {
			return this.receiptService.findReceipt(Integer.parseInt(id));
		}
		return null;
	}

	public String getId() {
		return getHttpUtil().getRequestParameter("id");
	}

}
